package com.oss.controller.oss;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oss.common.BaseResponse;
import com.oss.dto.oss.trademanage.*;
import com.oss.entity.oss.TradeManage;
import com.oss.service.oss.TradeManageService;
import com.oss.vo.oss.trade.TradeManageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 交易管理
 */
@RestController
@RequestMapping("/tradeManage")
public class TradeManageController {
    @Autowired
    TradeManageService tradeManageService;

    @PostMapping("/selectByPage")
    public BaseResponse<IPage<TradeManageVO>> selectByPage(@RequestBody @Valid TradeManagePageDto dto){
        return BaseResponse.success(tradeManageService.selectByPage(dto));
    }
    @PostMapping("/getByID")
    public BaseResponse<TradeManage> getByID(@RequestBody @Valid TradeManageGetByIDDto dto){
        return BaseResponse.success(tradeManageService.getById(dto.getId()));
    }
    @PostMapping("/add")
    public BaseResponse<String> add(@RequestBody @Valid TradeManageAddDto dto){
        return BaseResponse.success(tradeManageService.add(dto));
    }
    @PostMapping("/update")
    public BaseResponse<String> updateData(@RequestBody @Valid TradeManageUpdateDto dto){
        return BaseResponse.success(tradeManageService.updateData(dto));
    }
    @PostMapping("/delete")
    public BaseResponse<String> delete(@RequestBody @Valid TradeManageDeleteDto dto){
        return BaseResponse.success(tradeManageService.delete(dto));
    }
    @PostMapping("/import")
    public BaseResponse<String> importData(@RequestBody @Valid TradeManageImportDto dto){
        return BaseResponse.success(tradeManageService.importData(dto));
    }
}